package com.darren.euc.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
@Table(name = "euc_contract_hire_purchase")
public class ContractHirePurchase implements Serializable {

	private static final long serialVersionUID = 7225410464606595171L;

	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	
	
	
	
	/**
	 * 分期顺序
	 */
	@Column(name = "hire_purchase_number")
	private Integer hirePurchaseNumber;  
	
	
	/**
	 * 所属合同
	 */
	@ManyToOne  
    @JoinColumn(name = "contract_id")  
	private Contract contract;
	
	
	/**
	 * 款项说明
	 */
	@Column(name = "hire_purchase_description")
	private String hirePurchaseDescription;
	
	
	/**
	 * 分期开始时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
	@Column(name = "hire_purchase_start",nullable=true,columnDefinition="datetime")
	private Date hirePurchaseStart;
	
	/**
	 * 分期结束时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
	@Column(name = "hire_purchase_end",nullable=true,columnDefinition="datetime")
	private Date hirePurchaseEnd;
	
	
	/**
	 * 帐单日
	 */
	@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
	@Column(name = "bill_date",nullable=true,columnDefinition="datetime")
	private Date bill_Date;
	
	/**
	 * 计划付款金额
	 */
	@Column(name = "hire_purchase_amount", nullable = true)
	private Double hirePurchaseAmount;
	
	
	/**
	 * 实际付款金额
	 */
	@Column(name = "real_payment_amount", nullable = true)
	private Double realPaymentAmount;
	
	/**
	 * 回款状态: 已回款, 未回款
	 */
	@Column(name = "hire_purchase_status")
	private String hirePurchaseStatus;
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
	@Column(name = "create_time",nullable=true,columnDefinition="datetime")
	private Date createTime;

	@Column(name = "create_user_id")
	private Integer createUserId;
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
	@Column(name = "last_modify_time",nullable=true,columnDefinition="datetime")
	private Date lastModifyTime;
	
	@Column(name = "last_modify_user_id")
	private Integer lastModifyUserId;
	
	
	@Column(name = "enable")
	private boolean enable = true;


	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}
	
	


	public Integer getHirePurchaseNumber() {
		return hirePurchaseNumber;
	}


	public void setHirePurchaseNumber(Integer hirePurchaseNumber) {
		this.hirePurchaseNumber = hirePurchaseNumber;
	}


	public Contract getContract() {
		return null;//contract;
	}


	public void setContract(Contract contract) {
		this.contract = contract;
	}


	public String getHirePurchaseDescription() {
		return hirePurchaseDescription;
	}


	public void setHirePurchaseDescription(String hirePurchaseDescription) {
		this.hirePurchaseDescription = hirePurchaseDescription;
	}


	public Date getHirePurchaseStart() {
		return hirePurchaseStart;
	}


	public void setHirePurchaseStart(Date hirePurchaseStart) {
		this.hirePurchaseStart = hirePurchaseStart;
	}


	public Date getHirePurchaseEnd() {
		return hirePurchaseEnd;
	}


	public void setHirePurchaseEnd(Date hirePurchaseEnd) {
		this.hirePurchaseEnd = hirePurchaseEnd;
	}

	

	public Date getBill_Date() {
		return bill_Date;
	}


	public void setBill_Date(Date bill_Date) {
		this.bill_Date = bill_Date;
	}


	public Double getHirePurchaseAmount() {
		return hirePurchaseAmount == null?0D:hirePurchaseAmount;
	}


	public void setHirePurchaseAmount(Double hirePurchaseAmount) {
		hirePurchaseAmount = hirePurchaseAmount == null?0D:hirePurchaseAmount;
		this.hirePurchaseAmount = (double) (Math.round(hirePurchaseAmount*100)/100.00);
	}


	public Double getRealPaymentAmount() {
		return realPaymentAmount == null?0D:realPaymentAmount;
	}


	public void setRealPaymentAmount(Double realPaymentAmount) {
		this.realPaymentAmount = realPaymentAmount;
	}


	public String getHirePurchaseStatus() {
		hirePurchaseStatus = "未回款";
		if(hirePurchaseAmount != null && realPaymentAmount != null && hirePurchaseAmount.equals(realPaymentAmount)){
			hirePurchaseStatus = "已回款";			
		}
		return hirePurchaseStatus;
	}


	public void setHirePurchaseStatus(String hirePurchaseStatus) {
		this.hirePurchaseStatus = hirePurchaseStatus;
	}


	public Date getCreateTime() {
		return createTime;
	}


	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


	public Integer getCreateUserId() {
		return createUserId;
	}


	public void setCreateUserId(Integer createUserId) {
		this.createUserId = createUserId;
	}


	public Date getLastModifyTime() {
		return lastModifyTime;
	}


	public void setLastModifyTime(Date lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}


	public Integer getLastModifyUserId() {
		return lastModifyUserId;
	}


	public void setLastModifyUserId(Integer lastModifyUserId) {
		this.lastModifyUserId = lastModifyUserId;
	}


	public boolean isEnable() {
		return enable;
	}


	public void setEnable(boolean enable) {
		this.enable = enable;
	}
	
}
